<?php
	class Taller extends Utiles{

		private $id;
		private $imagen;
		private $nombre;
		private $detalles;
		private $profesores;
		private $fecha_inicio;
		private $inversion;

		public function __construct($id = 0){
			$this->id = $id;
			if($this->id > 0){
				$sql = "SELECT * FROM talleres WHERE id_taller = ".$id;
				$query = new Consulta($sql);
				if($query->NumeroRegistros() > 0){
					$row = $query->VerRegistro();
					$this->imagen 			= $row['imagen'];
					$this->nombre 			= $row['nombre'];
					$this->detalles 		= $row['detalles'];
					$this->profesores		= $row['profesores'];
					$this->fecha_inicio 	= $row['fecha_inicio'];
					$this->inversion 		= $row['inversion'];
				}					
			}
		}

		public function __get($atributo){
			return $this->$atributo;
		}

		public function getTalleres(){
			$sql = "SELECT * FROM talleres ORDER BY id_taller DESC";
			$query = new Consulta($sql);
			while( $row = $query->VerRegistro() ){
				$result[] = array(
					'id'			=> $row['id_taller'],
					'imagen'		=> $row['imagen'],
					'nombre'		=> $row['nombre'],
					'detalles' 		=> $row['detalles'],
					'profesores' 	=> $row['profesores'],
					'fecha_inicio'	=> $row['fecha_inicio'],
					'inversion'		=> $row['inversion']
				);
			}
			return $result;		
		}

		public function getTalleresLimit($ini, $num_reg){
			$sql = "SELECT * FROM talleres ORDER BY id_taller DESC LIMIT ".$ini.",".$num_reg."";
			$query = new Consulta($sql);
			while( $row = $query->VerRegistro() ){
				$result[] = array(
					'id'			=> $row['id_taller'],
					'imagen'		=> $row['imagen'],
					'nombre'		=> $row['nombre'],
					'detalles' 		=> $row['detalles'],
					'profesores' 	=> $row['profesores'],
					'fecha_inicio'	=> $row['fecha_inicio'],
					'inversion'		=> $row['inversion']
				);
			}
			return $result;		
		}

		public function getTallerRand(){
			$sql = "SELECT * FROM talleres ORDER BY RAND() LIMIT 1";
			$query = new Consulta($sql);
			while( $row = $query->VerRegistro() ){
				$result[] = array(
					'id'			=> $row['id_taller'],
					'imagen'		=> $row['imagen'],
					'nombre'		=> $row['nombre'],
					'detalles' 		=> $row['detalles'],
					'profesores' 	=> $row['profesores'],
					'fecha_inicio'	=> $this->formatear_fecha($row['fecha_inicio']),
					'inversion'		=> $row['inversion']
				);
			}
			return $result;		
		}

	}
?>